<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <hr />
    <div>姓名:{{ obj.name }}</div>
    <div>年龄:{{ obj.age }}</div>
    <hr />
    <div @click="changeObj1Name">obj1姓名:{{ obj1.name }}</div>
    <div>obj1年龄:{{ obj1.age }}</div>
  </div>
</template>

<script>
import { reactive, ref } from "vue";
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  setup() {
    const obj = {
      name: "张三",
      age: "26",
    };

    const obj1 = reactive(obj);
    const changeObj1Name = () => {
      obj1.name += "风";
    };
    return {
      obj,
      obj1,
      changeObj1Name,
    };
  },

  // vue2写法
  // data() {
  //   const count = 2;
  //   return {
  //     count: count,
  //   };
  // },
  // methods: {
  //   changeCout() {
  //     this.count++;
  //   },
  // },
};
</script>

<style scoped>
</style>
